#-*-encoding=utf-8-*-
steps = [
    FlowStep(
        name=u'init',
        title=u'需求建议',
        fields=[u'title', u'description', u'reason', u'module'],
        trigger=ur"""""",
        responsibles=u'[request.principal.id]',
    actions=[
        FlowStepAction(
            name=u'提交',
            title=u'提交',
            nextsteps=[u'deliever'],
            trigger=ur"""ITagsManager(sheet).addTag('讨论', True)""",
            condition=u'True'
)
])
,

    FlowStep(
        name=u'deliever',
        title=u'需求裁定',
        fields=[u'title', u'description', u'solution', u'reason', u'version', u'module', u'designer', u'developer', u'tester'],
        trigger=ur"""notifier_message.send(title='new request: ' + sheet['title'],
              body=sheet['description'],
              to_ids=task.responsibles + 
              flowsettings['product_team'] + 
              flowsettings['design_team'] + flowsettings['test_team'] ,
              bound_obj=sheet)
""",
        responsibles=u'flowsettings["deliverer"]',
    actions=[
        FlowStepAction(
            name=u'分派',
            title=u'接受此需求',
            nextsteps=[u'design', u'devdesign'],
            trigger=ur"""ITagsManager(sheet).addTag('接受', True)"""
),

        FlowStepAction(
            name=u'不是故障',
            title=u'暂不考虑',
            nextsteps=[],
            trigger=ur"""ITagsManager(sheet).addTag('拒绝', True)"""
),

        FlowStepAction(
            name=u'完成',
            title=u'以后再考虑',
            nextsteps=[u'deliever'],
            trigger=ur"""ITagsManager(sheet).addTag('推延', True)"""
)
])
,

    FlowStep(
        name=u'confirm',
        title=u'验收',
        fields=[u'title', u'description'],
        trigger=ur"""notifier_message.send(title='bug confirm: ' + sheet['title'],
              body=sheet['description'],
              to_ids=task.responsibles,
              bound_obj=sheet)
""",
        responsibles=u'sheet["creators"]',
    actions=[
        FlowStepAction(
            name=u'确认故障已经解决',
            title=u'需求已经满足',
            nextsteps=[],
            trigger=ur"""ITagsManager(sheet).addTag('验收', True)"""
),

        FlowStepAction(
            name=u'再次提交',
            title=u'再次提交',
            nextsteps=[],
            trigger=ur"""ITagsManager(sheet).addTag('处理', True)"""
)
])
,

    FlowStep(
        name=u'test',
        title=u'测试',
        fields=[],
        responsibles=u'sheet["tester"]',
    actions=[
        FlowStepAction(
            name=u'测试不通过',
            title=u'测试不通过',
            nextsteps=[u'devdesign']
),

        FlowStepAction(
            name=u'测试通过，请验收',
            title=u'测试通过，请验收',
            nextsteps=[u'confirm'],
            finish_condition=u''
)
])
,

    FlowStep(
        name=u'design',
        title=u'产品设计',
        fields=[u'solution', u'reason', u'version', u'module'],
        trigger=ur"""notifier_message.send(title='new design request: ' + sheet["title"],
              body=sheet['description'],
              to_ids=task.responsibles,
              bound_obj=sheet)
""",
        condition=u'sheet["designer"]',
        responsibles=u'sheet["designer"]',
    actions=[
        FlowStepAction(
            name=u'完成',
            title=u'完成',
            nextsteps=[u'coding'],
            trigger=ur"""ITagsManager(sheet).addTag('产品设计完成')"""
)
])
,

    FlowStep(
        name=u'devdesign',
        title=u'开发设计',
        fields=[],
        responsibles=u'sheet["developer"]',
    actions=[
        FlowStepAction(
            name=u'设计不完善',
            title=u'产品设计不完善，打回',
            nextsteps=[u'design'],
            finish_condition=u''
),

        FlowStepAction(
            name=u'开发完成，请测试',
            title=u'完成设计',
            nextsteps=[u'test'],
            trigger=ur"""ITagsManager(sheet).addTag('开发设计完成')"""
)
])
,

    FlowStep(
        name=u'coding',
        title=u'程序编码',
        fields=[],
        condition=u"'开发设计完成' in ITagsManager(sheet).listTags() and '产品设计完成' in ITagsManager(sheet).listTags() ",
        responsibles=u'sheet["developer"]',
    actions=[
        FlowStepAction(
            name=u'产品设计不充分，打回',
            title=u'产品设计不充分，打回',
            nextsteps=[u'design'],
            trigger=ur"""ITagsManager(sheet).delTag('产品设计完成') """
),

        FlowStepAction(
            name=u'开发设计不充分，打回',
            title=u'开发设计不充分，打回',
            nextsteps=[u'devdesign'],
            trigger=ur"""ITagsManager(sheet).delTag('开发设计完成') """
),

        FlowStepAction(
            name=u'编码完成',
            title=u'编码完成',
            nextsteps=[u'test'],
            finish_condition=u''
)
])
]
